package com.wulaoda.bilimanage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wulaoda.bilimanage.entity.ChargeEntity;
import com.wulaoda.bilimanage.entity.UserInfoEntity;
import com.wulaoda.bilimanage.mapper.ChargeMapper;
import com.wulaoda.bilimanage.mapper.UserInfoMapper;
import com.wulaoda.bilimanage.req.ChargeReq;
import com.wulaoda.bilimanage.resp.PageResp;
import com.wulaoda.bilimanage.service.ChargeService;
import com.wulaoda.bilimanage.service.UserInfoService;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;


@Service
public class ChargeServiceImpl extends ServiceImpl<ChargeMapper, ChargeEntity> implements ChargeService {

    @Resource
    ChargeMapper chargeMapper;

    @Override
    public PageResp<ChargeEntity> getList(ChargeReq req) {
        QueryWrapper<ChargeEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(ChargeEntity::getStatus, "false");
        Page<ChargeEntity> page = new Page<>(req.getPage(), req.getSize());
        IPage<ChargeEntity> chargeEntityIPage = chargeMapper.selectPage(page, queryWrapper);
        System.out.println(chargeEntityIPage.getRecords());

        PageResp<ChargeEntity> pageResp = new PageResp<>();
        pageResp.setTotal(chargeEntityIPage.getTotal());
        pageResp.setList(chargeEntityIPage.getRecords());
        return pageResp;
    }


}
